<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<script type="text/javascript">
	$(document).ready(function(){
		$("#totalPrice").click(function(){
 			$.ajax({
				type:"post",
				url:"salesPriceContentView.do?sellerId="+$("#sellerId").text(),
				dataType:"json",
				success:function(jsonData){
					$("#result").html("");
					var tbody="";
					$.each(jsonData,function(index,list){
						tbody+="<tr><td id='sellerId'>"+list.sellerId+"</td>";
						tbody+="<td>"+list.productName+"</td>";
						tbody+="<td>"+list.productMaker+"</td>";
						tbody+="<td>"+list.productPrice+"</td>";
						tbody+="<td>"+list.inventoryVO.salesVolume+"</td>";
						tbody+="<td bgcolor=yellow>"+list.productPrice * list.inventoryVO.salesVolume+"</td></tr>";	
					});
					$("#result").html(tbody);
				}
 			});
		});
		$("#totalVolume").click(function(){
			location.href="salesVolumeContentView.do?sellerId="+$("#sellerId").text();
		});
	});
</script>

<h3>개인 판매자 통계</h3>
<input type="button" id="totalVolume" value="총 판매량 정렬">
<input type="button" id="totalPrice" value="총 수익 정렬">
<br><br>
<table border="1" cellpadding="5" width="700" id="sellerView">
	<thead align="center">
		<tr>
			<th>판매자 ID</th>
			<th>상품명</th>
			<th>메이커</th>
			<th>상품 가격</th>
			<th>상품 판매량</th>
			<th>상품 판매수익</th>
		</tr>
	</thead>
	<tbody align="center" id="result">
		<c:forEach var="list" items="${requestScope.list}">		
			<tr>
			    <td id="sellerId">${list.sellerId }</td>										
				<td>${list.productName }</td>
				<td>${list.productMaker }</td>
				<td>${list.productPrice }</td>
				<td bgcolor=yellow>${list.inventoryVO.salesVolume }</td>
				<td>${list.productPrice * list.inventoryVO.salesVolume }</td>
			</tr>		
		</c:forEach>
	</tbody>
</table>